<style>
/* 重写样式 */
.fui-header.block {
    display: block;
}

.fui-tab {
    margin: 0;
}

.fui-tab a {
    height: 2.2rem;
    line-height: 2.2rem;
}

.fui-tab:after {
    display: none;
}
.nickname {
    color: #50b6fe;
}
    .shop-index-page .menu {height: auto; background: #fff;}
    .shop-index-page .menu .item {height: auto; width: 1%; padding: 0.5rem 0; margin: 0; font-size: 0.7rem; color: #636363; text-align: center; display: table-cell;position: relative;}
    .shop-index-page .menu .item:after  {font-size: 0.7rem;position: absolute;content: '';left:-1px;top:0.5rem;bottom:0.5rem;border-left:1px solid #d9d9d9;}
    .content-empty{padding:1rem 0;margin:0;}
source{
    min-width: 100%;
    min-height: 100%;
    height: auto;
    width: auto;
}
	.btn{border-radius: 100%;border: 0 solid #ebebeb;margin: 0.25rem;}
	.btn-logo.active{border: 2px solid #3263fe;}
	.btn-logo {
			padding:0px;
			height:2rem;
			width:2rem;
			border-radius: 100%;
			border: 2px solid #ebebeb;
	}
	.label-gray{
		background-color:#f2f2f2;
		color:#333;
		border-radius:1rem;
		padding:0.3rem;
		font-size:0.7rem
	}
	.label-gray.active{
		background-color:#e8fcf8;
		color:#18bc9c;
	}
</style>
<div class='fui-page fui-page-current'>
	<div ng-include="sys_html('common/_header')"></div>
	<div class="fui-content">
	<div class="jy-topbg" style="top:0;">
	<div class="jy-content" style="padding-top: 0.3rem;padding-bottom:1rem;">
		<div class="fui-tab-scroll" style="padding-bottom:0;height:2.4rem">
			<div ng-class="{'item':1,'on':pagedata.params.type==0}"><a href="javascript:" ng-click="pagedata.params.type=0;">设备信息</a></div>
			<div ng-class="{'item':1,'on':pagedata.params.type==1}"><a href="javascript:" ng-click="pagedata.params.type=1;tool.get_list('/mcpitem/getmymp3list/',true)">音乐</a></div>
			<div ng-class="{'item':1,'on':pagedata.params.type==2}"><a href="javascript:" ng-click="pagedata.params.type=2;tool.get_list('/mcpitem/getimglist/',true)">壁纸</a></div>
		</div>
		<div ng-if="pagedata.params.type==0">
		<div class="fui-cell-group radius">
			<div class="fui-cell" style="padding:0.35rem;">
				<div  class="fui-cell-lable" style="width:auto;padding-right: 0.3rem;">
					<img style="border-radius: 100%;width:3.3rem;height:3.3rem" ng-src="{{tomedia(pagedata.item.agent.logo) || '../addons/jy_agentmcp/resource/images/goods.png'}}" />
				</div>
				<div  class="fui-cell-info" style="">
					<div class="bold">{{pagedata.item.title||'设备名称'}}  <i ng-if="!pagedata.show2upmcp" class="icon icon-shuru bold red" ng-click="pagedata.show2upmcp=true"></i></div>
					<div class="gray">{{pagedata.item.mcpurl||'接入点***'}}</div>
					<div class="gray">
						<div ng-if="pagedata.item.status==1" class="btn btn-sm btn-blue jy-btn2" style="color:#fff;border-radius:0.2rem">在线</div>
						<div ng-if="pagedata.item.status!=1" class="btn btn-sm btn-success jy-btn1" style="color:#999;border-radius:0.2rem">离线</div>
					</div>
				</div>
			</div>
		</div>
		<div class="fui-cellone" style="padding-top: 0;margin-top:1rem">
			<div class="fui-cellone-text">
				<div class="radius c jy-btn2" ng-click="pagedata.upmcpurl()" style="border-radius:1rem;color:#fff;padding:0.7rem">
					刷新MCP
				</div>
			</div>
		</div>
		<div ng-if="pagedata.show2upmcp">
		<div class="fui-cell-group radius">
			<div class="fui-cell">
				<div class="fui-cell-label bold">名称</div>
				<div class="fui-cell-info"><input type="text" class='fui-input' placeholder="设置名称" ng-model="pagedata.item.title"/></div>
			</div>
		</div>
		<div ng-if="!pagedata.item.agentapiid || pagedata.item.agentapiid==0" class="fui-cell-group radius">
			<div class="fui-cell">
				<div class="fui-cell-info">
					<div class="bold" style="padding-bottom: 0.3rem;">MCP接入点</div>
					<textarea style="height: 6rem" id="desc" ng-model="pagedata.item.mcpurl" placeholder="请输入MCP接入点"></textarea>
				</div>
			</div>
		</div>
		<div class="fui-cellone" style="padding-top: 0;margin-top:1rem">
			<div wx:if="{{pagedata.post.status==1}}" class="fui-cellone-text" style="padding-right:0.5rem">
				<div class="radius c jy-btn1" ng-click="pagedata.show2upmcp=false" style="border-radius:1rem;color:red;padding:0.7rem">
					关闭
				</div>
			</div>	
			<div class="fui-cellone-text">
				<div class="radius c jy-btn2" ng-click="pagedata.postmcp()" style="border-radius:1rem;color:#fff;padding:0.7rem">
					保存
				</div>
			</div>
		</div>
		</div>
		</div>
		<div ng-if="pagedata.params.type==1" ng-include="sys_html('common/_mymp3list')"></div>
		<div ng-if="pagedata.params.type==2" ng-include="sys_html('common/_myimglist')"></div>
	</div>
	</div>
	<div ng-include="sys_html('common/_copyright',true)"></div>
</div>
</div>
<div ng-include="sys_html('common/_footer')"></div>
<script>
scope.pagedata.show2upmcp=true;
var action='jy_agentmcp/mcpitem/getmp3log/';
if(scope.pagedata.params.type==2){
	action='jy_agentmcp/mcpitem/getimglist/';
}
if(scope.pagedata.params.type==1 && scope.pagedata.params.ismymp3==1){
	action='jy_agentmcp/mcpitem/getmymp3list/';
}
scope.tool.get_list(action);
scope.pagedata.scroll_bottom=function(){
	action='jy_agentmcp/mcpitem/getmp3log/';
	if(scope.pagedata.params.type==2){
		action='jy_agentmcp/mcpitem/getimglist/';
	}
	if(scope.pagedata.params.type==1 && scope.pagedata.params.ismymp3==1){
		action='jy_agentmcp/mcpitem/getmymp3list/';
	}
	scope.tool.get_list(action);
}
scope.pagedata.postmcp=function(){
	scope.post_json('/editmcp/post/',scope.pagedata.item,function(res){
		if(scope.pagedata.item.mcpurl){
			scope.get_data(scope.pagedata,'upmcpinfo','/mcpitem/upmcpurl/id='+scope.pagedata.item.id);
			scope.pagedata.item.status=1;
			scope.$evalAsync();
		}
		scope.message('操作成功！');
	});
}
scope.pagedata.upmcpurl=function(){
	scope.get_data(scope.pagedata,'upmcpinfo','/mcpitem/upmcpurl/id='+scope.pagedata.item.id,'','',true);
	setTimeout(function(){
		scope.pagedata.item.status=1;
		scope.$evalAsync();
		//scope.message('刷新成功！');
	},500);
}
if(scope.pagedata.needup==1 && scope.pagedata.item.id){
	scope.get_data(scope.pagedata,'upmcpinfo','/mcpitem/upmcpurl/id='+scope.pagedata.item.id);
	scope.pagedata.item.status=1;
	scope.$evalAsync();
}
scope.pagedata.scancode=function () {
			wx.scanQRCode({
				needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
				scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
				success: function (res) {
					var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
					result=result.replace('EAN_13,', '');
					scope.pagedata.item.productsn = result;
					scope.$evalAsync();
				}
			});
}
</script>